from appium import webdriver
from selenium.webdriver.remote.webdriver import WebDriver

from page.base_page import BasePage
from page.main_page import MainPage


class App:
    driver: WebDriver = None
    @classmethod
    def start(cls):
        devices = "192.168.11.166:6666"
        # devices = "192.168.123.170:6666"
        caps = {}
        caps["platformName"] = "android"
        caps["deviceName"] = devices
        caps["appPackage"] = "com.xqxc.customer"
        caps["appActivity"] = "com.xqxc.home_module.ui.activity.MainActivity"
        # caps["autoGrantPermissions"] = True
        caps["noReset"] = True
        caps["skipServerInstallation"] = True
        caps["skipDeviceInitialization"] = True

        cls.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
        cls.driver.implicitly_wait(10)
        return MainPage(cls.driver), BasePage(cls.driver)
    @classmethod
    def quit(cls):
        cls.driver.quit()
        return cls